package com.study.Controller;

import com.common.Entity.Result;
import com.study.Entity.Section;
import com.study.Service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/section")
public class SectionController {
    @Autowired
    private SectionService sectionService;

    @GetMapping("/getSectionList/{articleId}")
    public Result getSectionList(@PathVariable("articleId") String articleId) {
        return Result.success(sectionService.getSectionList(articleId));
    }

    @PostMapping("/addSection")
    public Result addSection(@RequestBody Section section) {
        sectionService.addSection(section);
        return Result.success();
    }

    @PutMapping("/updateSection")
    public Result updateSection(@RequestBody Section section) {
        sectionService.updateSection(section);
        return Result.success();
    }

    @DeleteMapping("/deleteSection/{sectionId}")
    public Result deleteSection(@PathVariable("sectionId") String sectionId) {
        sectionService.deleteSection(sectionId);
        return Result.success();
    }

}
